package com.ltedu.oss.utils;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.vod.model.v20170321.GetPlayInfoRequest;
import com.aliyuncs.vod.model.v20170321.GetPlayInfoResponse;

import java.util.List;

/**
 * @className: AliyunVodSDKUtils
 * @auther: Jerry
 * @date: 2020/12/10 14:56
 * @desctiption: TODO
 * @version: 1.0
 */
public class AliyunVodSDKUtils {

    public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException {
        // 点播服务接入区域
        String regionId = "cn-shanghai";
        DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
        DefaultAcsClient client = new DefaultAcsClient(profile);
        return client;
    }

    public static void main(String[] args) throws ClientException {
        DefaultAcsClient client = AliyunVodSDKUtils.initVodClient(
                "LTAI1r6Crveenmli",
                "DeLV7f4zA4WLkUGeAHe9V2gB2kfs9h");
        GetPlayInfoRequest request = new GetPlayInfoRequest();
        request.setVideoId("4a78f81e7b1848c2a4c0324145669ae9");
        GetPlayInfoResponse response = new GetPlayInfoResponse();
        response = client.getAcsResponse(request);
        List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList();
        //播放地址
        for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) {
            System.out.print("PlayInfo.PlayURL = " + playInfo.getPlayURL() + "\n");
        }
        //Base信息
        System.out.print("VideoBase.Title = " + response.getVideoBase().getTitle() + "\n");
    }
}
